--- a/cmake/FindGtest.cmake	2013-11-13 09:19:50 +0000
+++ b/cmake/FindGtest.cmake	2020-01-13 20:50:16 +0000
@@ -1,53 +1,31 @@
-include(ExternalProject)
 include(FindPackageHandleStandardArgs)
 
 #gtest
-set(GTEST_INSTALL_DIR /usr/src/gmock/gtest/include)
+set(GTEST_INSTALL_DIR /usr/src/gmock/gtest)
 find_path(GTEST_INCLUDE_DIR gtest/gtest.h
-            HINTS ${GTEST_INSTALL_DIR})
+            HINTS ${GTEST_INSTALL_DIR}/include)
 
 #gmock
-find_path(GMOCK_INSTALL_DIR gmock/CMakeLists.txt
-          HINTS /usr/src)
-if(${GMOCK_INSTALL_DIR} STREQUAL "GMOCK_INSTALL_DIR-NOTFOUND")
-    message(FATAL_ERROR "google-mock package not found")
-endif()
-
-set(GMOCK_INSTALL_DIR ${GMOCK_INSTALL_DIR}/gmock)
-find_path(GMOCK_INCLUDE_DIR gmock/gmock.h)
-
-set(GMOCK_PREFIX gmock)
-set(GMOCK_BINARY_DIR ${CMAKE_BINARY_DIR}/${GMOCK_PREFIX}/libs)
-set(GTEST_BINARY_DIR ${GMOCK_BINARY_DIR}/gtest)
-
-set(GTEST_CMAKE_ARGS "")
-if (${MIR_IS_CROSS_COMPILING})
-    set(GTEST_CMAKE_ARGS
-        -DCMAKE_TOOLCHAIN_FILE=${CMAKE_MODULE_PATH}/LinuxCrossCompile.cmake)
-endif()
-
-ExternalProject_Add(
-    GMock
-    #where to build in source tree
-    PREFIX ${GMOCK_PREFIX}
-    #where the source is external to the project
-    SOURCE_DIR ${GMOCK_INSTALL_DIR}
-    #forward the compilers to the subproject so cross-arch builds work
-    CMAKE_ARGS ${GTEST_CMAKE_ARGS}
-    BINARY_DIR ${GMOCK_BINARY_DIR}
-
-    #we don't need to install, so skip
-    INSTALL_COMMAND ""
-)
-
-set(GMOCK_LIBRARY ${GMOCK_BINARY_DIR}/libgmock.a)
-set(GMOCK_MAIN_LIBRARY ${GMOCK_BINARY_DIR}/libgmock_main.a)
+set(GMOCK_INSTALL_DIR /usr/src/gmock)
+find_path(GMOCK_INCLUDE_DIR gmock/gmock.h
+            HINST ${GMOCK_INSTALL_DIR}/include)
+
+find_library(GMOCK_LIBRARY gmock HINTS ${GMOCK_INSTALL_DIR} PATH_SUFFIXES lib)
+find_library(GMOCK_MAIN_LIBRARY gmock_main HINTS ${GMOCK_INSTALL_DIR} PATH_SUFFIXES lib)
+find_library(GTEST_LIBRARY gtest HINTS ${GTEST_INSTALL_DIR} PATH_SUFFIXES lib)
+find_library(GTEST_MAIN_LIBRARY gtest_main HINTS ${GTEST_INSTALL_DIR} PATH_SUFFIXES lib)
+
 set(GMOCK_BOTH_LIBRARIES ${GMOCK_LIBRARY} ${GMOCK_MAIN_LIBRARY})
-set(GTEST_LIBRARY ${GTEST_BINARY_DIR}/libgtest.a)
-set(GTEST_MAIN_LIBRARY ${GTEST_BINARY_DIR}/libgtest_main.a)
 set(GTEST_BOTH_LIBRARIES ${GTEST_LIBRARY} ${GTEST_MAIN_LIBRARY})
 set(GTEST_ALL_LIBRARIES ${GTEST_BOTH_LIBRARIES} ${GMOCK_BOTH_LIBRARIES})
 
+if(${GMOCK_LIBRARY} STREQUAL "GMOCK_LIBRARY-NOTFOUND")
+    message(FATAL_ERROR "google-mock package not found")
+endif()
+if(${GTEST_LIBRARY} STREQUAL "GTEST_LIBRARY-NOTFOUND")
+    message(FATAL_ERROR "google-test package not found")
+endif()
+
 find_package_handle_standard_args(GTest  DEFAULT_MSG
                                     GMOCK_INCLUDE_DIR
                                     GTEST_INCLUDE_DIR)

